package com.hzhr.iot.statis.dao;

import com.hzhr.iot.statis.dao.mapper.custom.DeviceHourlyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.dao.mapper.generator.DeviceHourlyGasConsumeEntityMapper;
import com.hzhr.iot.statis.entity.DeviceHourlyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.DeviceHourlyGasConsumeEntityExt;
import com.hzhr.iot.statis.queryModel.custom.DeviceHourlyGasConsumeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class DeviceHourlyGasConsumeDao {
    @Autowired
    DeviceHourlyGasConsumeEntityMapper deviceHourlyGasConsumeEntityMapper;
    @Autowired
    DeviceHourlyGasConsumeEntityCustomMapper deviceHourlyGasConsumeEntityCustomMapper;

    public int insert(DeviceHourlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deviceHourlyGasConsumeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deviceHourlyGasConsumeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(DeviceHourlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deviceHourlyGasConsumeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deviceHourlyGasConsumeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public DeviceHourlyGasConsumeEntityExt selectEntity(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceHourlyGasConsumeEntityExt> extList = deviceHourlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceHourlyGasConsumeEntity> selectEntityList(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceHourlyGasConsumeEntityExt> extList = deviceHourlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<DeviceHourlyGasConsumeEntity> entityList = new ArrayList<>();
        for (DeviceHourlyGasConsumeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public DeviceHourlyGasConsumeEntityExt selectExt(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceHourlyGasConsumeEntityExt> extList = deviceHourlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceHourlyGasConsumeEntityExt> selectExtList(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceHourlyGasConsumeEntityExt> extList = deviceHourlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public int selectCount(DeviceHourlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = deviceHourlyGasConsumeEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
